<%@page contentType="text/html" pageEncoding="UTF-8" import="org.acme.server.TOServer, java.util.HashSet"%>
<%
  HashSet<TOServer> authServers = (HashSet<TOServer>) request.getAttribute("authServers");
  if(null == authServers)
    authServers = new HashSet<TOServer>();

  int frmKey = 0;
  String x;

%><?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Server Administration Page</title>
    <style type="text/css">
<!--
body,td,th {
	font-family: Verdana, Geneva, sans-serif;
	font-size:12px;
}
.msgStat{
	font-size:16px;
	text-align:center;
	background-color:#FFC;
	color:#666;
}
body {
	background-color: #C63;
	text-align:center;
	padding:0;
	margin:0;
	background-image:url(/images/orange-server.png);
	background-repeat:no-repeat;
}
h1{
	font-size:18px;
	color:#FFF;
}
h5{
	font-size:14px;
	color:#FFF;	
}
.container{
	width:700px;
	margin-left:auto;
	margin-right:auto;
	min-height:400px;
}
.tblFrm{
	width:100%;
	text-align:center;
	border:1px solid #F00;
	background:#FFF;
}

input{
	border: 1px solid #333;
}

.trodd{
  background: beige;
}

.treven{
  background: bisque;
}

-->
</style></head>
    <body>
    	<div class="container">
        <div style="float:right;"><a href="<%= request.getAttribute("logoutURL") %>"><img border="0" src="/images/logout.png" alt="log-out" /></a></div>
        <h1>Authorized Servers</h1>
        <p style="color:aliceblue">!! Warning Restarting the application will lead to data loss</p>
        <div class="msgStat"><%= request.getAttribute("msgStat") == null ? "" : request.getAttribute("msgStat") %></div>

        <table class="tblFrm" cellpadding="1" cellspacing="1">
          <thead bgcolor="#333333" style="color: #FFC;">
        		<tr>
              <th height="26"  >IP Address</th>
                  <th >Access Code</th>
                    <th colspan="2">Actions</th>
                </tr>
            </thead>
            <tbody>
            <% for (TOServer server : authServers){ frmKey++; %>
            <tr class="<%= (frmKey%2) == 0 ? "trodd" : "treven" %>">
            <form action="/admin/updateOrDelete" method="post" id="frm_upd<%=frmKey %>">
            
              <td><input name="ipAddress" type="text" value="<%=server.getIPAddress() %>" /></td>
              <td><input name="accessCode" type="text" value="<%=server.getAuthCode() %>" /></td>
              <td width="19%" style="text-align:left"><input type="submit" name="ax" value="update" /></td>
              <td width="17%" style="text-align:right"><input type="submit" name="ax" value="delete" />
              <!-- original values -->
              <input type="hidden" name="ipAddressOrig" value="<%=server.getIPAddress() %>" />
              <input type="hidden" name="accessCodeOrig" value="<%=server.getAuthCode() %>" />
              </td>
          </form>
          </tr>
          <% }%>
          <tr>
          <form action="/admin/add" method="post" id="frm_add">
            <td><input name="ipAddress" type="text" value="" /></td>
            <td><input name="accessCode" type="text" value="" /></td>
            <td colspan="2" style="text-align:left"><input type="submit" value="add " /></td>
          </form>
          </tr>
        </tbody>
          </table>
          <hr/>


        </div>
    </body>
</html>
